package com.yutianran.springBoot.spider;

public class Node {
    private static final String PREFIX = "    ";

    int level;
    String name;
    String link;

    public Node(String name) {
        this(0, name, null);
    }

    public Node(String name, String link) {
        this(0, name, link);
    }

    public Node(int level, String name, String link) {
        this.level = level;
        this.name = name;
        this.link = link;
    }

    public Node(int level) {
        this.level = level;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLink() {
        return link;
    }

    public void setLink(String link) {
        this.link = link;
    }

    @Override
    public String toString() {
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < level; i++) {
            stringBuilder.append(PREFIX);
        }
        if (name != null) {
            stringBuilder.append("- ").append(name).append(" ");
        }
        if (link != null) {
            stringBuilder.append(link);
        }
        return stringBuilder.toString();
    }
}
